package com.hooper.iot.resource.entity;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DeviceFeignRes {

    private String code;

    private Integer status;

    private Long timestamp;

    private DeviceResult result;

    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class DeviceResult {

        private Integer pageNo;

        private Integer pageSize;

        private Integer total;

        private Integer totalPages;

        private List<DeviceData> data;
    }

    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class DeviceData {
        private String id;
        private String gbid;
        //2022/3/22临时测试使用（一台设备即作为人脸门禁又作为录像使用，区域入侵播放视频需求，此字段临时配置人脸设备对应录像设备的devId）
        //private String address;
        //将address临时使用字段改为关联国标id字段
        private String relatedGbid;
        private String name;
        private String deviceType;
        private String deviceName;
        // 0-在线 1-离线
        private String status;
        private String groupId;
        private String areaGrougId;
        private String areaGroupName;
        private DeviceAttr deviceAttr;
        private String businessCode;
        private String password;
        private String desc;
        private String updaterName;
        private Float longitude;
        private Float latitude;
        private String ipv4;
    }

    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class DeviceAttr {
        // 安防主机
        private Ismpdev ismpdev;
        // 安防输入设备
        private IsmpNode ismpnode;
        // 安防网关
        private IsmpAdpter ismpadpter;
        // 人脸门禁终端
        private Faceterminal faceterminal;
        // 门禁主机
        private AcessControl acesscontrol;
        // 车辆道闸
        private BarrierGate barriergate;
        // 开关量主机
        // switch 为关键字，不可使用
        @JSONField(name = "switch")
        private Switch aSwitch;
        // 智能分析服务器
        private IAS ias;
        // 报警主机
        private Alarm alarm;
        // 智能抓拍（原猎鹰）
        private IntelligentCapture intelligentcapture;
        // 车卡
        private VB vb;
        // 巡更主机
        private Patrol patrol;
        // 对讲主机
        private Intercom intercom;
    }

    /**
     * 安防主机
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class Ismpdev {
        // TODO 此字段不确定
        private String nodeNo;
        private Integer layerType;
        private String type;
        private String chnId;
        private String code;
        private String devNameInitials;
        private String modelId;
        private String validFlag;
        private String serverPort;
        private String advCfg;
        private String subnetMask;
        private String adpId;
        private String serverHost;
        private String accessId;
        private String businessCode;
        private String subInfo;
        private String phone;
        private String organCode;
        private int defendFlag;
        private int invalid;
        private String manuFacId;
        private String subType;
        private String gateWay;
        private int direction;
        private String relateDevIP;
    }

    /**
     * 安防输入设备
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class IsmpNode {
        private String type;
        private Integer layerType;
        private String nodeNo;
        private String devNameInitials;
        private String advInfo;
        private String extInfoId;
        private String validFlag;
        // 所属安防主机设备
        private String ismpDevPid;
        // 父设备
        private String ismpNodePid;
        // 所属设备
        private String ownerDevId;
        private String nodeArea;
        private String source;
        private String subInfo;
        private String organCode;
        // 是否布防
        private int defendFlag;
        private String ability;
    }

    /**
     * 安防网关（适配器）
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class IsmpAdpter {
        private Integer layerType;
        private String code;
        private String organCode;
        // 主控端-1，辅控端-0
        private Integer type;
        // 同步-1，不同步-0
        private Integer sync;
        private String adpNameInitials;
    }

    /**
     * 人脸门禁终端
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class Faceterminal {
        private String organCode;
        // 接入ID
        private String accessId;
        // 视频通道ID
        private String chnId;
        // 1-TCP
        private List<String> conType;
        // 1-迎宾机 2-科达人脸
        private String subType;
        // 适配器ID
        private String adpId;
        // 0-无效 1-入口 2-出口 3-出入口
        private String direction;
    }

    /**
     * 门禁主机
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class AcessControl {
        private List<String> conType;
        private String organCode;
        private String adpId;
        private String serverHost;
        private Integer serverPort;
    }

    /**
     * 车辆道闸
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class BarrierGate {
        private String conType;
        private String organCode;
        private String adpId;
        private String serverHost;
        private Integer serverPort;
    }

    /**
     * 开关量主机
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class Switch {
        private String conType;
        private String organCode;
        private String adpId;
        private String serverHost;
        private Integer serverPort;
    }

    /**
     * 智能分析服务器
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class IAS {
        private String conType;
        private String organCode;
        private String adpId;
        private String serverHost;
        private Integer serverPort;
    }

    /**
     * 报警主机
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class Alarm {
        private String conType;
        private String organCode;
        private String adpId;
        private String serverHost;
        private Integer serverPort;
    }

    /**
     * 智能抓拍
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class IntelligentCapture {
        private String conType;
        private String organCode;
        private String adpId;
        private String serverHost;
        private Integer serverPort;
    }

    /**
     * 车辆卡口
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class VB {
        private String organCode;
        // 接入ID
        private String accessId;
        // 视频通道ID
        private String chnId;
        // 1-TCP
        private List<String> conType;
        // 1-车辆卡口
        private String type;
        // 适配器ID
        private String adpId;
        // 0-无效 1-入口 2-出口 3-出入口
        private String direction;
    }

    /**
     * 巡更主机
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class Patrol {
        private String conType;
        private String organCode;
        private String adpId;
        private String serverHost;
        private Integer serverPort;
    }

    /**
     * 对讲主机
     */
    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class Intercom {
        private String conType;
        private String organCode;
        private String adpId;
        private String serverHost;
        private Integer serverPort;
    }

    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class OtherGroupIds {
        private String area;
        private String department;
    }

    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class OtherGroupNames {
        private String area;
    }

    @Data
    @NoArgsConstructor
    @Builder
    @AllArgsConstructor
    public static class OtherNames {
        private String originStatus_name;
        private String status_name;
    }

//    @Data
//    @NoArgsConstructor
//    @Builder
//    @AllArgsConstructor
//    public static class OtherPermissions {
//    }
}
